/**
 * 
 */
package com.ywm8.ywm.admin.action;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.ServletContext;

import org.apache.struts2.util.ServletContextAware;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionSupport;
import com.ywm8.ywm.admin.service.AdminService;
import com.ywm8.ywm.admin.service.MenuService;
import com.ywm8.ywm.admin.service.NoticeService;
import com.ywm8.ywm.admin.service.ShopService;
import com.ywm8.ywm.domain.Admin;
import com.ywm8.ywm.domain.Menu;
import com.ywm8.ywm.domain.Notice;
import com.ywm8.ywm.domain.Shop;

/**
 * @author wangruishun
 * @version ywm8 1.0 2014-3-12 下午5:42:02
 */
@Controller("userAction")
@Scope("prototype")
public class UserAction extends ActionSupport implements ServletContextAware {

	private static final long serialVersionUID = -1026836727168473769L;
	private ServletContext sc;
	private Notice nc;
	private Shop sp;
	private Admin sb;
	private List<Shop> sps1;
	private List<Shop> sps2;
	private List<Admin> ans;
	private List<Notice> nes;
	private List<Menu> mus;
	@Resource
	private ShopService shopS;
	@Resource
	private AdminService adminS;
	@Resource
	private NoticeService noticeS;
	@Resource
	private MenuService menuS;

	/**
	 * 显示选择的校区
	 * 
	 * @return
	 */
	public String firstComeIn() {
		String hql = "from Admin";
		ans = adminS.findEntityByHQL(hql);
		return SUCCESS;
	}

	/**
	 * index显示
	 */
	public String indexShow() {
		String hql = "from Notice n where n.aid=? and n.isShow=1";
		nes = noticeS.findEntityByHQL(hql, sb.getId());
		String hql1 = "from Shop s where s.aid=? and s.isvalid=1 and s.evaluate=1";
		sps1 = shopS.findEntityByHQL(hql1, sb.getId());
		String hql2 = "from Shop s where s.aid=? and s.isvalid=1 and s.evaluate=0";
		sps2 = shopS.findEntityByHQL(hql2, sb.getId());
		return SUCCESS;
	}

	/**
	 * 显示菜
	 */
	public String shopShow() {
		String hql = "from Menu m where m.isvalid=1 and m.shopId=?";
		mus=menuS.findEntityByHQL(hql, sp.getId());
		return SUCCESS;
	}

	/**
	 * @return the nc
	 */
	public Notice getNc() {
		return nc;
	}

	/**
	 * @return the mus
	 */
	public List<Menu> getMus() {
		return mus;
	}

	/**
	 * @param mus
	 *            the mus to set
	 */
	public void setMus(List<Menu> mus) {
		this.mus = mus;
	}

	/**
	 * @param nc
	 *            the nc to set
	 */
	public void setNc(Notice nc) {
		this.nc = nc;
	}

	/**
	 * @return the nes
	 */
	public List<Notice> getNes() {
		return nes;
	}

	/**
	 * @param nes
	 *            the nes to set
	 */
	public void setNes(List<Notice> nes) {
		this.nes = nes;
	}

	/**
	 * @return the sp
	 */
	public Shop getSp() {
		return sp;
	}

	/**
	 * @param sp
	 *            the sp to set
	 */
	public void setSp(Shop sp) {
		this.sp = sp;
	}

	/**
	 * @return the sps1
	 */
	public List<Shop> getSps1() {
		return sps1;
	}

	/**
	 * @param sps1
	 *            the sps1 to set
	 */
	public void setSps1(List<Shop> sps1) {
		this.sps1 = sps1;
	}

	/**
	 * @return the sps2
	 */
	public List<Shop> getSps2() {
		return sps2;
	}

	/**
	 * @param sps2
	 *            the sps2 to set
	 */
	public void setSps2(List<Shop> sps2) {
		this.sps2 = sps2;
	}

	/**
	 * @return the ans
	 */
	public List<Admin> getAns() {
		return ans;
	}

	/**
	 * @return the sb
	 */
	public Admin getSb() {
		return sb;
	}

	/**
	 * @param sb
	 *            the sb to set
	 */
	public void setSb(Admin sb) {
		this.sb = sb;
	}

	/**
	 * @param ans
	 *            the ans to set
	 */
	public void setAns(List<Admin> ans) {
		this.ans = ans;
	}

	public void setServletContext(ServletContext arg0) {
		this.sc = arg0;
	}

}
